package com.example.practice2023.service;

import com.example.practice2023.mapper.UserMapper;
import com.example.practice2023.pojo.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * ClassName: UserService
 * Package: com.example.practice2023.service
 * Description:
 *
 * @Author hyx
 * @Create 2023/7/3 0:16
 * @Version 1.0
 */
@Service
public class UserService {
    @Resource
    private UserMapper userMapper;

    public Map<String,Object> selectByUserName(String username,String password) {
        Map<String, Object> map = new HashMap<>();
        User user = userMapper.selectByUserName(username);
        if(user!=null&&user.getPassWord().equals(password)){
            map.put("code",200);
            map.put("msg","登录成功");
            map.put("username", username);
        }
        else {
            map.put("code", 50001);
            map.put("msg", "用户名或者密码错误");
        }

        return map;
    }
}
